# -*- coding: utf-8 -*-
#高级特性----迭代  如果给定一个list或tuple，我们可以通过for循环来遍历这个list或tuple，这种遍历我们称为迭代（Iteration）

import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')

a = {'a':1,'b':2,'c':3}

for key in a:
	print(key)

for k,v in a.items():
	print(k,'=',v)
	
for ch in 'ABC':
	print(ch)

for key,value in enumerate(a):
	print(key,value)

for x,y in [(1,2),(2,3),(3,4)]:
	print(x,y)


def findMinAndMax(L):
	if len(L) == 0:
		return (None,None)
		
	min = max = L[0]

	for v in L:
		if v < min:
			min = v
		elif v > max:
			max = v
	return (min,max)

# 测试
if findMinAndMax([]) != (None, None):
    print('测试失败!')
elif findMinAndMax([7]) != (7, 7):
    print('测试失败!')
elif findMinAndMax([7, 1]) != (1, 7):
    print('测试失败!')
elif findMinAndMax([7, 1, 3, 9, 5]) != (1, 9):
    print('测试失败!')
else:
    print('测试成功!')
